Skip to content

chore: iaw uses org setting insted of feature flag #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

CatalinSnyk
Copy link
Contributor

@CatalinSnyk CatalinSnyk commented Aug 5, 2025

Previously, the IAW create workflow was gated behind a feature flag check. For EA, customers should be able to opt in/out of using the ignore approval, so a new org setting was added for them to toggle on/off.

This PR just swaps out the feature flag check with an fetching the org settings and checking whether IAW is enabled for the current org before proceeding with the ignore create workflow.

Ref: CLI-1006

Copy link

snyk-io bot commented Aug 5, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

code/snyk check is complete. No issues have been found. (View Details)

Copy link

snyk-io bot commented Aug 5, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

code/snyk check is complete. No issues have been found. (View Details)

@CatalinSnyk CatalinSnyk marked this pull request as ready for review August 5, 2025 12:23
@CatalinSnyk CatalinSnyk requested review from a team as code owners August 5, 2025 12:23
if !config.GetBool(configuration.FF_IAW_ENABLED) {
return nil, cli.NewFeatureUnderDevelopmentError("")
if !config.GetBool(configIgnoreApprovalEnabled) {
return nil, snyk_errors.Error{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change this to an error coming from the Error Catalog before merging.

cursor[bot]

This comment was marked as outdated.

@@ -247,6 +248,28 @@ func (a *snykApiClient) GetSastSettings(orgId string) (*sast_contract.SastRespon
return &response, err
}

func (a *snykApiClient) GetOrgSettings(orgId string) (*contract.OrgSettingsResponse, error) {
endpoint := fmt.Sprintf("%s/v1/org/%s/settings", a.url, url.QueryEscape(orgId))
res, err := a.client.Get(endpoint)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: use clientGet() instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added it, only think I don't especially like is the fact that clientGet is for versioned API's and the one we are using is v1, but I'm guessing it should be fine?

@CatalinSnyk CatalinSnyk force-pushed the chore/CLI-1006_iaw_use_org_setting branch from 5db2d8a to 49856e6 Compare August 12, 2025 07:54
@CatalinSnyk CatalinSnyk requested review from a team as code owners August 12, 2025 07:54
cursor[bot]

This comment was marked as outdated.

@@ -0,0 +1,16 @@
package contract

type OrgIgnoreSettings struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: please link to the API spec this relates to

@@ -43,6 +44,32 @@ func addCreateIgnoreDefaultConfigurationValues(invocationCtx workflow.Invocation
})
}

func getOrgIgnoreApprovalEnabled(engine workflow.Engine) configuration.DefaultValueFunction {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: please add a test

@CatalinSnyk CatalinSnyk force-pushed the chore/CLI-1006_iaw_use_org_setting branch from 0d97852 to b5fd0d9 Compare August 12, 2025 16:15
}

return &response, err
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Incorrect Endpoint and Missing Status Code Handling

The GetOrgSettings function uses the incorrect endpoint /v1/org/{orgId}/settings instead of /v1/orgs/{orgId}/settings, which will cause 404 errors in production. Additionally, it fails to check HTTP status codes. For any non-200 response (e.g., 404, 401, 403) with a JSON body, json.Unmarshal succeeds into a zero-valued OrgSettingsResponse. This causes callers to misinterpret API, authentication, or network failures as the Ignore Approval Workflow being "disabled," silently blocking the feature with a misleading message. A status code check (e.g., for 200 OK) should be added, or clientGet used.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants